package db

import (
	"github.com/google/uuid"
	"gomonitor-server/src/mylog"
	"time"
)

func RecordConnectLog(ip string, port int, connectType int) {
	id := uuid.New().String()
	createdTime := time.Now()

	dbTool, err := GetConnection()
	if err != nil {
		// 处理错误
		mylog.Logger.Error("连接MySQL失败", err)
		return
	}
	_, err = dbTool.Exec("insert into t_connection_log (id, created_time, ip, port, connect_type) "+
		"values (?,?,?,?,?)", id, createdTime, ip, port, connectType)
	if err != nil {
		// 处理错误
		mylog.Logger.Error("插入数据失败", err)
	}

}
